package com.mj.listen1._09_Set集合;

public class Main {
    public static void main(String[] args) {
//        listSet();
        treeSet();
    }

    private static void listSet() {
        ListSet<Integer> listSet = new ListSet<>();
        listSet.add(11);
        listSet.add(22);
        listSet.add(33);
        listSet.add(44);
        listSet.add(44);
        listSet.add(55);

        listSet.remove(44);
        listSet.traversal(new Set.Visitor<Integer>() {
            @Override
            public boolean visit(Integer element) {
                System.out.print(element + ",");
                return false;
            }
        });
    }

    private static void treeSet() {
        TreeSet<Integer> treeSet = new TreeSet<>();
        // 56, 38, 89, 69, 12, 55, 93, 20, 18, 92, 61, 87, 51, 68, 49, 41, 26
        treeSet.add(56);
        treeSet.add(38);
        treeSet.add(89);
        treeSet.add(69);
        treeSet.add(12);
        treeSet.add(55);
        treeSet.add(93);
        treeSet.add(20);
        treeSet.add(18);
        treeSet.add(92);
        treeSet.add(61);
        treeSet.add(87);
        treeSet.add(51);
        treeSet.add(68);
        treeSet.add(49);
        treeSet.add(41);
        treeSet.add(26);
        treeSet.add(26);

        treeSet.remove(55);
        treeSet.remove(92);


        treeSet.traversal(new Set.Visitor<Integer>() {
            @Override
            public boolean visit(Integer element) {
                System.out.print(element + ",");
                return false;
            }
        });
    }
}
